<?php
/**
 * Created by PhpStorm.
 * User: liuxiaojie
 * Date: 2019-03-10
 * Time: 22:51
 */

namespace app\ops\controller;

class Goodscategory extends Base

{

    function index()
    {
        $list = db('goods_category')->where(['status'=> 1])->select();

        $this->assign('list', $list);
        return $this->fetch();
    }

    function edit($id = 0)
    {
        $post = request()->post();
        if($post)
        {
            if($post['id'])
            {
                db('goods_category')->update($post);
            }else{
                unset($post['id']);
                db('goods_category')->insert($post);
            }
            return success([]);
        }else{
            $data = db('goods_category')->where(['id'=> $id])->find();
            $this->assign('data', $data);
            return $this->fetch();
        }
    }


    function delete()
    {
        $id = request()->post('id');
        db('goods_category')->where(['id'=> $id])->update(['status'=> 0]);
        return success([]);
    }
}